﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace server
{
    public partial class money : Form
    {
        Maticsoft.Model.RoleInfo mUserInfo = new Maticsoft.Model.RoleInfo();
        Maticsoft.DAL.RoleInfo mUserAction = new Maticsoft.DAL.RoleInfo();

        public money()
        {
            InitializeComponent();
            this.btnAdd.Enabled = false;
            this.cmbMonth.Text = "1";
        }

        private void btnFind_Click(object sender, EventArgs e)
        {
            this.mUserInfo = this.mUserAction.GetModel(this.textUsername.Text);
            if (this.mUserInfo == null)
            {
                MessageBox.Show("没有这个用户");
                this.btnAdd.Enabled = false;
            }
            else
            {
                MessageBox.Show("找到用户，用户过期时间："+ this.mUserInfo.setupDate);
                
                this.btnAdd.Enabled = true;
            }
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            DateTime dt = Convert.ToDateTime( this.mUserInfo.setupDate);
            if (dt < DateTime.Now)
            {
                dt = DateTime.Now;
            }
            dt = dt.AddMonths(Convert.ToInt16(this.cmbMonth.Text));

            this.mUserInfo.setupDate = dt.ToString();

            this.mUserAction.Update(this.mUserInfo);

            MessageBox.Show("用户过期时间：" + this.mUserInfo.setupDate);
        }
    }
}
